package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Chat;
import cn.wolfcode.trip.base.domain.FriendRelation;
import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.ChatMapper;
import cn.wolfcode.trip.base.mapper.FriendRelationMapper;
import cn.wolfcode.trip.base.mapper.UserMapper;
import cn.wolfcode.trip.base.query.ChatQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.UserQueryObject;
import cn.wolfcode.trip.base.service.IChatService;
import cn.wolfcode.trip.base.service.IUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class ChatServiceImpl implements IChatService {

    @Autowired
    private ChatMapper chatMapper;
    @Override
    public void insert(Chat chat) {
        chat.setCreateTime(new Date());
        chatMapper.insert(chat);
    }

    @Override
    public PageInfo showChatContent(ChatQueryObject qo) {
        List<Chat> list = chatMapper.selectForList(qo);
        qo.setState(true);
        chatMapper.updateState(qo);
        return new PageInfo<>(list);
    }

    @Override
    public Map<String, Integer> listChatNumber(ChatQueryObject qo) {

        Map<String, Integer> map = chatMapper.selectChatNumber(qo);
        return map;
    }
}
